export default (router, services, middlewares) => {
    router.post('/middle/login', middlewares.handler, async (ctx, next) => {
        const data = ctx.request.body;
        const res = await services.auth.login(data, ctx);
        ctx.cookies.set(
            'x-mars-token', res.data, {
                httpOnly: false,  // 是否只用于http请求中获取
                overwrite: true,
                expires: 0  // 是否允许重写
            })
        ctx.cookies.set(
            'name', data.userName, {
                httpOnly: false,  // 是否只用于http请求中获取
                overwrite: true,
                expires: 0  // 是否允许重写
            })
        ctx.cookies.set(
            'isLogin', true, {
                httpOnly: false,  // 是否只用于http请求中获取
                overwrite: true,
                expires: 0  // 是否允许重写
            })
        ctx.body = res.data;
    })
}